@echo off
echo ========================================
echo 简单API测试
echo ========================================

echo.
echo 1. 测试系统状态...
powershell -Command "try { $result = Invoke-RestMethod -Uri 'http://localhost:8081/api/home/system-status' -Method GET; Write-Host '系统状态:' $result.message } catch { Write-Host '系统状态失败:' $_.Exception.Message }"

echo.
echo 2. 测试设备API（使用WebRequest）...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8081/api/devices/user/3' -Method GET; Write-Host 'HTTP状态:' $response.StatusCode; Write-Host '内容长度:' $response.Content.Length; if ($response.Content.Length -gt 0) { Write-Host '内容:' $response.Content } else { Write-Host '内容为空' } } catch { Write-Host '设备API失败:' $_.Exception.Message }"

echo.
echo 3. 测试设备API（使用RestMethod）...
powershell -Command "try { $result = Invoke-RestMethod -Uri 'http://localhost:8081/api/devices/user/3' -Method GET; Write-Host '设备数量:' $result.Count; if ($result.Count -gt 0) { Write-Host '设备列表:'; $result | ForEach-Object { Write-Host '  -' $_.name '(' $_.room ')' } } else { Write-Host '没有设备' } } catch { Write-Host 'RestMethod失败:' $_.Exception.Message }"

echo.
echo ========================================
echo 测试完成
echo ========================================
pause
